<template>
	<view class="newcontent">
		<view v-for="(data,index) in list" :key="index" class="index-item" @click="bindClick(data.id,data.link)">
			<view v-if="data.class == 'noimg'" :class="data.class">
				<view :class="['newtitle','fontsize'+fontsizenub]">{{data.title}}</view>
				<view class="commonshow">
					<view class="seenub"><text class="'nubdata">{{data.uploadTime}}</text></view>
					<view class="seenub" v-if="data.label"><text class="'nubdata">{{data.label}}</text></view>
				</view>
			</view>
			<view v-if="data.class == 'frist-img'" class="oneimg"> 
				<view class="frist-img">
					<view class="firstimgbox">
						<image :src="localurl+data.picture" mode="widthFix"></image>
					</view>
					<view class="fristinfo">
						<view :class="['newtitle','fontsize'+fontsizenub]">{{data.title}}</view>
						<view class="commonshow">
							<view class="seenub"><text class="'nubdata">{{data.uploadTime}}</text></view>
							<view class="seenub" v-if="data.label"><text class="'nubdata">{{data.label}}</text></view>
						</view>
					</view>
				</view>
			</view>
			<view v-if="data.class == 'oneimg'"  :class="[data.class,'oneimger']">
				<view class=".imgfather">
					<image :src="localurl+data.picture" class="imageonly"/></image>
				</view>
				<view class="oneimgbox">
					<view :class="['newtitle','fontsize'+fontsizenub]">{{data.title}}</view>
					<view class="commonshow">
						<view class="seenub"><text class="'nubdata">{{data.uploadTime}}</text></view>
						<view class="seenub" v-if="data.label"><text class="'nubdata">{{data.label}}</text></view>
					</view>
				</view>
			</view>
			<view v-if="data.class == 'threeimg'" :class="[data.class]">
				<view :class="['newtitle','fontsize'+fontsizenub]">{{data.title}}</view>
				<view class="threeimgbox">
					<view class="smbox">
						<image :src="localurl+data.picture"/></image>
					</view>
					<view class="smbox">
						<image :src="localurl+data.picture1"/></image>
					</view>
					<view class="smbox">
						<image :src="localurl+data.picture2"/></image>
					</view>
				</view>
				<view class="commonshow">
					<view class="seenub"><text class="'nubdata">{{data.uploadTime}}</text></view>
					<view class="seenub" v-if="data.label"><text class="'nubdata">{{data.label}}</text></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {common} from '@/common/publish.js';
	import {mapState,mapMutations} from 'vuex';
	export default {
		data() {
			return {
				list:[]
			};
		},
		onLoad(option){
			let id = option.url;
			uni.request({
				url:common.url+'/api/newsCentre/specialSecond.json',
				data:{
					relationId:id
				},
				success:(res)=>{
					if(res.statusCode == 200){
						res.data.rows.forEach((v)=>{
							if(v.displayType == '多图'){
								v.class = 'threeimg'
							}else if(v.displayType == '纯文字'){
								v.class = 'noimg' 
							}else if(v.displayType == '单图'){
								v.class = 'oneimg'
							}else if(v.displayType == '广告'){
								v.class = 'frist-img'
							}
							if(v.label.length>7)v.label = v.label.substring(0,6) + '...';
						})
						this.list = res.data.rows;
						console.log(this.list)
					}
				}
			})
		},
		computed:{
			...mapState(['fontsizenub'])
		},
		methods:{
			bindClick(id,link){
				if(link){
					//如果连接存在 ==》 外链
					var	reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
					var wherefrom = reg.test(link);
					if(wherefrom){
						uni.navigateTo({
							url: '/pages/webview/webview?type=index&id='+id
						});
					}else{
						uni.navigateTo({
							url: '/pages/xq/xq?type=index&id='+id
						});
					}	
				}else{
					//本地
					uni.navigateTo({
						url: '/pages/xq/xq?type=index&id='+id
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '../.././static/iconfont.css';
	@import '@/common/publish.scss';
	@include fontsizefn(".zbtt",32upx);
	@include fontsizefn(".newtitle",32upx);
	.nubdata{
		font-size:26upx;
	}
</style>
